<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>菜单页面</title>
<s:include value="/app_common/common.jsp"></s:include>
<!-- 树start-->
<script type="text/javascript" src="<s:property value='webctx'/>/libs/js/tree/ztree/ztree.js"></script>
<link href="<s:property value='webctx'/>/libs/js/tree/ztree/ztree.css" rel="stylesheet" type="text/css"/>
<style type="text/css">
.ztree *{
	font-family:sans-serif!important;
}
.ztree li span.button.switch.level1 {visibility:hidden; width:1px;}
/*.ztree li ul.level1 {padding:0; background:none;}*/
</style>
<!-- 树end-->
<!-- 选项卡start -->
<script type="text/javascript" src="<s:property value='webctx'/>/libs/js/nav/dynamicTab.js"></script>
<!-- 选项卡end -->
<script type="text/javascript">
//新增replaceAll方法
String.prototype.replaceAll = function(s1,s2) { 
   	return this.replace(new RegExp(s1,"gm"),s2); 
}

var setting = {
		view: {
			dblClickExpand: dblClickExpand
		},data: {
			simpleData: {
				enable: true
			}
		},callback: {
			onClick: onClick
		}
	};
	//禁止双击
	function dblClickExpand(treeId, treeNode) {
		return treeNode.level > 0;
	}
	var json_val = "<s:property value='json_val' escape='false' />";
	
	var zNodes = json_val.toJSON();
	/*escapeXml="" escapeJavaScript=""
	[
		{ id:3000, parentId:0, name:"基本功能"},
		{ id:001, parentId:3000, name:"部门管理",url:"../../sample/index/function.html", target:"frmright"},
		{ id:002, parentId:3000, name:"角色管理",url:"../../sample/index/css.html", target:"frmright"},
		{ id:003, parentId:3000, name:"用户管理",url:"../../sample/index/icons.html", target:"frmright"}
	];*/
	
	function initComplete(){
		$.fn.zTree.init($("#treeDemo"), setting, zNodes);
		//每次刷新时保持上次打开的
		showContent();
	}
	function showContent(){
		var treeNodeId=jQuery.jCookie('leftTreeNodeId');
		if(treeNodeId==false||treeNodeId=="false"){}
		else{
			var zTree = $.fn.zTree.getZTreeObj("treeDemo");
			var node = zTree.getNodeByParam("id", treeNodeId);
			zTree.selectNode(node);
			if(node.urls){
				//alert($('.tab_title',window.top.document).length);
				var nodeId = 'tab1_index'+node.id;
				tab.add( {
					id :nodeId,
					title :node.name,
					url :node.urls,
					isClosed :true
				});
				//alert("2:"+$('#'+nodeId).length);
				if($('#'+nodeId,window.top.document).length==0){
					showProgressBar();
				}
				//top.frmright.location=node.url;
			}
		}
	}
	function onClick(e,treeId, treeNode){
		//单击展开
		var zTree = $.fn.zTree.getZTreeObj("treeDemo");
		if(treeNode.vision){
			if(treeNode.vision!="disabled"){
				zTree.expandNode(treeNode);
			}
		}
		//出现进度条
		if(treeNode.urls!=null){
			var nodeId = 'tab1_index'+treeNode.id;
			//alert(nodeId+":"+$('#'+nodeId,window.top.document).length);
			tab.add( {
				id :nodeId,
				title :treeNode.name,
				url :treeNode.urls,
				isClosed :true
			})
			//alert("1:"+$('#'+nodeId).length);
			if($('#'+nodeId,window.top.document).length==0){
				showProgressBar();
			}
		}
		
		//可以设置某些页面出现或者某些页面不出现当前位置组件
		if(treeNode.name=="当前位置"){
			//每次点击时设置当前位置内容
			top.positionContent="当前位置："+treeNode.getParentNode().name+">>"+treeNode.name;
			top.positionType="normal";
		}
		else{
			top.positionType="none";
		}
		
		//存储点击节点id
		jQuery.jCookie('leftTreeNodeId',treeNode.id.toString());
	}

	function  showAll(){
		var treeObj=$.fn.zTree.getZTreeObj("treeDemo");
		treeObj.expandAll(true);
	}
	function  hideAll(){
		var treeObj = $.fn.zTree.getZTreeObj("treeDemo")
		treeObj.expandAll(false);
	}
	 var tab = new TabView( {
			containerId :'tab_menu',
			pageid :'page',
			cid :'tab1',
			position :"top"
		});
	$(function(){
			/* 
			tab.add( {
				id :'tab1_index1',
				title :"选项卡1",
				url :"/app/yjbg/yjbg_queryYjbg.action",
				isClosed :true
			}); */
			
		});
</script>
</head>
<body leftFrame="true" style="background-color:#f1f8ff">
<div class="padding_top5 ali02">
	<a onclick="showAll()">全部展开</a>&nbsp;&nbsp;<a onclick="hideAll()">全部收缩</a>
</div>
<div id="scrollContent">
	<div>
		<ul id="treeDemo" class="ztree"></ul>
	</div>
</div>
</body>
</html>